﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data.Sql;

namespace RestaurantManagerWebApp.Pages.StockManagement.New
{
    public partial class InventoryAdd : System.Web.UI.Page
    {
        string connection = System.Configuration.ConfigurationManager.ConnectionStrings["DB_RM"].ConnectionString;
        protected void Page_Load(object sender, EventArgs e)
        {
            string selectSQL = "SELECT c_name FROM DB_RM.dbo.Category";

            SqlConnection con = new SqlConnection();
            SqlCommand cmd = new SqlCommand(selectSQL, con);
            SqlDataReader reader;

        }
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(connection);
            conn.Open();

            String itemName = txtItemName.Text;
            int qty = Convert.ToInt32(txtQty.Text);

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection = conn;

                cmd.CommandText = "Insert into Ingredient (i_name, i_quantity, m_id, c_id) Values (@itemName, @qty, '1', '4')";
                cmd.Parameters.AddWithValue("@itemName", itemName);
                cmd.Parameters.AddWithValue("@qty", qty);

                cmd.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                Response.Write(ex.Message);
            }
            conn.Close();

        }
}
}